package com.sgc.view;

import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import com.architecture.view.PadraoManutencaoMB;
import com.archtecture.control.enums.TipoOrdenacao;
import com.sgv.model.entities.CompraModel;
import com.sgv.model.entities.FornecedorModel;

@ManagedBean(name = "compraMB")
@ViewScoped
public class CompraMB extends PadraoManutencaoMB<CompraModel> {

	private List<FornecedorModel> listFornecedor;

	@PostConstruct
	public void iniciarComponentes() {
		executarPesquisar();
	}

	@Override
	protected String[] getAtributosOrdenacao() {
		return new String[] { "data" };
	}

	@Override
	protected CompraModel getInstance() {
		CompraModel lModel = new CompraModel();
		lModel.setFornecedor(new FornecedorModel());
		return lModel;
	}

	@SuppressWarnings("unchecked")
	public List<FornecedorModel> getListFornecedor() {
		if (listFornecedor == null) {
			listFornecedor = montarCombo(new FornecedorModel(), TipoOrdenacao.ASC, "nome");
		}
		return listFornecedor;
	}

}
